<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use yii\helpers\ArrayHelper;
use common\models\business\BusinessAdress;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\business\models\BusinessPutSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '投放计划';
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">
 


<div class="business-put-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


    <?= GridView::widget([
        'dataProvider'=>$dataProvider,
        'filterModel'=>$searchModel,
        'showPageSummary'=>true,
        'pjax'=>true,
        'striped'=>true,
        'hover'=>true,
        'panel'=>['type'=>'primary', 'heading'=>'投放计划'],
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
        'columns'=>[
            [
                'attribute'=>'id',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],

            [
                'attribute'=>'person',
                'value' => 'putperson.name',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'cunid',
                'value' => 'village.name',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=>ArrayHelper::map(BusinessAdress::allVillage(),'id','name'),
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'村'],
            ],
            [
                'attribute'=>'num',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'class' => '\kartik\grid\ActionColumn',
                'deleteOptions' => ['label' => '<i class="glyphicon glyphicon-remove"></i>'],
                'options' => ['width' => '100px;'],
                'template' => '{view} {update} {delete} {detail}',
                'buttons' => [
                    'detail' => function ($url, $model) {
                        return Html::label('<span class="glyphicon glyphicon-list"></span>','#',[
                            'title' => '详情','class'=>'pdetail','data-id'=>$model->id,
                        ]);
                    }
                ],
            ],
        ],
        'toolbar'=> [
            '{export}',
            '{toggleData}',
        ],
        'bordered'=>true,
        'condensed'=>true,
    ]);
    ?>


</div>
</div>
</div>
</section>
</section>



<!--投放计划详情-->
<?php
\yii\bootstrap\Modal::begin([
    'id' => 'putdetail',
    'header' => '<h4 class="modal-title">投放计划详情</h4>',
    'footer' => '<a href="#" class="btn btn-primary" data-dismiss="modal">关闭</a>',
]);
/*ajax 填充*/
\yii\bootstrap\Modal::end();
?>
<script>
    <?php $this->beginBlock('js_end') ?>
        $('.pdetail').click(function () {
            $('#putdetail').attr('data-id',$(this).data('id'));
            var requestUrl = '<?php echo \yii\helpers\Url::to(['pdetail'])?>';
            $.get(requestUrl, {putid:$(this).data('id')},
                function (data) {
                    $('#putdetail  .modal-body').html(data);
                }
            );
            $('#putdetail').modal()
        });
    <?php $this->endBlock(); ?>
    <?php $this->registerJs($this->blocks['js_end'],\yii\web\View::POS_END);//将编写的js代码注册到页面底部 ?>
</script>
<!--投放计划详情end-->




